package com.hzyl.famousreader.view.activity;

import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.v7.app.AppCompatActivity;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.SPUtils;
import com.umeng.analytics.MobclickAgent;
import com.hzyl.famousreader.Constant;
import com.hzyl.famousreader.R;
import com.hzyl.famousreader.router.Router;

/**
 * 启动页
 */
public class SplashActivity extends AppCompatActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    new CountDownTimer(3000, 1000) {
      @Override
      public void onTick(long millisUntilFinished) {

      }

      @Override
      public void onFinish() {
        boolean beGuided = SPUtils.getInstance().getBoolean(Constant.SP_BE_GUIDED, false);
        if (beGuided) {
          ARouter.getInstance().build(Router.ACTIVITY_MAIN).navigation();
        } else {
          ARouter.getInstance().build(Router.ACTIVITY_GUIDE).navigation();
        }
        finish();
      }
    }.start();
  }

  @Override
  protected void onPause() {
    super.onPause();
    MobclickAgent.onPageEnd("首屏页");
    MobclickAgent.onPause(this);
  }

  @Override
  protected void onResume() {
    super.onResume();
    MobclickAgent.onPageStart("首屏页");
    MobclickAgent.onResume(this);
  }
}
